package collections

/**
 *@author LikeYouDo
 *@date 2024/12/13 09:14
 */
fun main() {
    val map = mapOf("key" to 42)

    println(map["key"])
    println(map["key2"])

    println(map.getValue("key"))

    val withDefault = map.withDefault { k -> k.length }
    println(withDefault.getValue("key2"))

    try {
        map.getValue("anotherKey")
    } catch (e: NoSuchElementException) {
        println("Message: $e")
    }


}